home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 428_02 / libsrc / editbox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-13  |  1.0 KB  |  47 lines

  1. /*
  2. ** editbox.c
  3. **
  4. ** Pictor, Version 1.51, Copyright (c) 1992-94 SoftCircuits
  5. ** Redistributed by permission.
  6. */
  7.  
  8. #include <string.h>
  9. #include "pictor.h"
  10.  
  11. /*
  12. ** Displays an edit box with a the given prompt and calls kbdedit()
  13. ** to let the user edit a string. Returns TRUE if the user pressed Enter;
  14. ** returns FALSE and buffer is unchanged if the user pressed escape.
  15. */
  16. int editbox(char *prompt,char *buffer,int maxlen,char *title,
  17.     COLORSTRUCT *colors)
  18. {
  19.     int i,top,left,retval,width,editwidth;
  20.  
  21.     editwidth = (maxlen + 1);
  22.     width = strlen(prompt) + editwidth + 6;
  23.     i = width - (_PL_columns - 10);
  24.     if(i > 0) {
  25.         editwidth -= i;
  26.         width -= i;
  27.     }
  28.  
  29.     top = center(3 + 2,_PL_rows);
  30.     left = center(width + 2,_PL_columns);
  31.     wopen(top,left,3 + 2,width + 2,colors->normal,WO_STATICMEM | WO_SHADOW);
  32.     wtitle(title);
  33.     setwpos(2,2);
  34.     wputs(prompt);
  35.     wputs(": [");
  36.     setwpos(2,width - 1);
  37.     wputc(']');
  38.  
  39.     retval = kbdedit(buffer,top + 2,left + strlen(prompt) + 5,
  40.         editwidth,maxlen,colors);
  41.  
  42.     wclose();
  43.  
  44.     return(retval);
  45.  
  46. } /* editbox */
  47.